#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File        :   225. 用队列实现栈.py    
@Contact     :   lhouctcs@163.com
@License     :   MIT
@Time        :   2023/2/10 17:55
@Author      :   lhou 
@Version     :   0.1.0
@Description :
"""
from collections import deque


# import lib
class MyStack:

    def __init__(self):
        self.que = deque()

    def push(self, x: int) -> None:
        self.que.append(x)

    def pop(self) -> int:
        if self.empty():
            return None
        for i in range(len(self.que) - 1):
            self.que.append(self.que.popleft())
        return self.que.popleft()

    def top(self) -> int:
        if self.empty():
            return None
        return self.que[-1]

    def empty(self) -> bool:
        return not self.que
